#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import functools

# 带一个参数的装饰器
def decorator(func):
    def wrapper(msg):
        print('wrapper of decorator 01')
        func(msg)
    return wrapper


# 带多个参数的装饰器
def decorators(func):
    def wrapper(*args, **kw):
        print('wrapper of decorator 02')
        func(*args, **kw)
    return wrapper


# 带自定义参数的装饰器
def repeat(num):
    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kw):
            for i in range(num):
                print('wrapper of decorator 03')
                func(*args, **kw)
        return wrapper
    return decorator


@decorators
def geet(*msg):
    for i in msg:
        print(i)

@repeat(3)
def g(*args):
    for i in args:
        print(i)

@decorator
@decorators
def gg(s):
    print(s)


print('func g name: %s' %gg.__name__)
help(gg)

# output
# g(1, 2, 33)
# geet(*['ss, work hard!', 'fightting'])
# geet('second', 'demo')
gg('ssfan')
